/*
 * @lc app=leetcode.cn id=49 lang=javascript
 *
 * [49] 字母异位词分组
 */

// @lc code=start
/**
 * @param {string[]} strs
 * @return {string[][]}
 */
var groupAnagrams = function(strs) {
    let hash=new Map()
    let str_help="abcdefghijklmnopqrstuvwxyz"
    for(let i=0;i<str_help.length;i++){
        hash.set(str_help[i],i)
    }
    let map=new Map()
    let res=[]
    for(let item of strs){
        let count_arr=new Array(26).fill(0)
        for(let i of item){
            count_arr[hash.get(i)]++
        }
        let temp=count_arr.toString()
        if(!map.has(temp)){
            map.set(temp,[item])
        }else{
            map.get(temp).push(item)
        }
    }
    map.forEach((item)=>{
        res.push(item)
    })
    return res
};
// @lc code=end
groupAnagrams (["eat","tea","tan","ate","nat","bat"])
